//
//  MatchClothes.swift
//  MyCloset
//
//  Created by 牟好好 on 2024/10/27.
//

import SwiftUI

// 返回所有可搭配属性
func findMatchingCombinations(features: [String], combinations: [[String]]) -> [String] {
    var matchingFeatures: Set<String> = []
    
    for combination in combinations {
        // isDisjoint 一个集合中是否没有与另一个集合相同的成员
        if !Set(combination).isDisjoint(with: Set(features)) {
            // 取并集
            matchingFeatures.formUnion(combination)
        }
    }

    return Array(matchingFeatures)
}

func findMatchingCount(features: [String], combinations: [String]) -> Int {
    // 交集数量
    let matchCount = Set(features).intersection(Set(combinations)).count
    print(matchCount)
    return matchCount
}
